package com.ruoyi.parttime.service.impl;

import java.time.*;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.parttime.Enum.RecruitState;
import com.ruoyi.parttime.domain.ParttimePlaza;
import com.ruoyi.parttime.mapper.ParttimePlazaMapper;
import com.ruoyi.parttime.service.IParttimePlazaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 兼职广场Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-02
 */
@Service
public class ParttimePlazaServiceImpl implements IParttimePlazaService
{
    @Autowired
    private ParttimePlazaMapper parttimePlazaMapper;

    /**
     * 查询兼职广场
     * 
     * @param id 兼职广场主键
     * @return 兼职广场
     */
    @Override
    public ParttimePlaza selectParttimePlazaById(Long id)
    {
        return parttimePlazaMapper.selectParttimePlazaById(id);
    }

    /**
     * 查询兼职广场列表
     * 
     * @param parttimePlaza 兼职广场
     * @return 兼职广场
     */
    @Override
    public List<ParttimePlaza> selectParttimePlazaList(ParttimePlaza parttimePlaza)
    {
        parttimePlaza.setRecruitmentStatus(RecruitState.NORMAL.getRecruitState());
        if(parttimePlaza.getCreateTime()!=null){
            LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(parttimePlaza.getCreateTime().getTime()), ZoneId.systemDefault());;
            parttimePlaza.setStartTime(localDateTime.with(LocalTime.MIN));;
            parttimePlaza.setEndTime(localDateTime.with(LocalTime.MAX));
        }
        return parttimePlazaMapper.selectParttimePlazaList(parttimePlaza);
    }
    /**
     * 获取兼职次数前5的数据
     *
     * @return List<ParttimePublish>
     */
    @Override
    public List<ParttimePlaza> selectParttimePublishTop() {
        return parttimePlazaMapper.selectParttimePublishTop();
    }
}
